home *** CD-ROM | disk | FTP | other *** search
/ Inter.Net 55-1 / Inter.Net 55-1.iso / CBuilder / Setup / BCB / data.z / stdio.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-02-09  |  16.5 KB  |  470 lines

  1. /*  stdio.h
  2.  
  3.     Definitions for stream input/output.
  4.  
  5. */
  6.  
  7. /*
  8.  *      C/C++ Run Time Library - Version 9.0
  9.  *
  10.  *      Copyright (c) 1987, 1998 by Borland International
  11.  *      All Rights Reserved.
  12.  *
  13.  */
  14. /* $Revision:   9.5  $ */
  15.  
  16. #ifndef __STDIO_H
  17. #define __STDIO_H
  18. #define _INC_STDIO  /* MSC Guard name */
  19.  
  20. #ifndef ___STDDEF_H
  21. #include <_stddef.h>
  22. #endif
  23.  
  24. #if !defined(___NFILE_H)
  25. #include <_nfile.h>
  26. #endif
  27.  
  28. #ifdef __cplusplus
  29. namespace std {
  30. #endif /* __cplusplus */
  31.  
  32.  
  33. #if !defined(RC_INVOKED)
  34.  
  35. #if defined(__STDC__)
  36. #pragma warn -nak
  37. #endif
  38.  
  39. #pragma pack(push, 1)
  40.  
  41. #endif  /* !RC_INVOKED */
  42.  
  43. /* Definition of the file position type
  44. */
  45. typedef long    fpos_t;
  46.  
  47. /* An external reference to _floatconvert (using #pragma extref _floatconvert)
  48.  * forces floating point format conversions to be linked.
  49.  */
  50. extern int _floatconvert;
  51.  
  52. /* Bufferisation type to be used as 3rd argument for "setvbuf" function
  53. */
  54. #define _IOFBF  0
  55. #define _IOLBF  1
  56. #define _IONBF  2
  57.  
  58. /*  "flags" bits definitions
  59. */
  60. #define _F_RDWR 0x0003                  /* Read/write flag       */
  61. #define _F_READ 0x0001                  /* Read only file        */
  62. #define _F_WRIT 0x0002                  /* Write only file       */
  63. #define _F_BUF  0x0004                  /* Malloc'ed Buffer data */
  64. #define _F_LBUF 0x0008                  /* line-buffered file    */
  65. #define _F_ERR  0x0010                  /* Error indicator       */
  66. #define _F_EOF  0x0020                  /* EOF indicator         */
  67. #define _F_BIN  0x0040                  /* Binary file indicator */
  68. #define _F_IN   0x0080                  /* Data is incoming      */
  69. #define _F_OUT  0x0100                  /* Data is outgoing      */
  70. #define _F_TERM 0x0200                  /* File is a terminal    */
  71.  
  72. /* End-of-file constant definition
  73. */
  74. #define EOF (-1)                /* End of file indicator */
  75. #define WEOF (_WINT_T)(0xFFFF)   /* wide-character end of file indicator */
  76.  
  77. /* Default buffer size use by "setbuf" function
  78. */
  79. #define BUFSIZ  512         /* Buffer size for stdio */
  80.  
  81. /* Size of an arry large enough to hold a temporary file name string
  82. */
  83. #define L_ctermid   5       /* CON: plus null byte */
  84. #define P_tmpdir    ""      /* temporary directory */
  85. #define L_tmpnam    13      /* tmpnam buffer size */
  86.  
  87. /* Constants to be used as 3rd argument for "fseek" function
  88. */
  89. #define SEEK_CUR    1
  90. #define SEEK_END    2
  91. #define SEEK_SET    0
  92.  
  93. /* Number of unique file names that shall be generated by "tmpnam" function
  94. */
  95. #define TMP_MAX     0xFFFF
  96.  
  97. /* Definition of the control structure for streams
  98. */
  99. typedef struct  {
  100.         unsigned char  *curp;       /* Current active pointer     */
  101.         unsigned char  *buffer;     /* Data transfer buffer       */
  102.         int             level;      /* fill/empty level of buffer */
  103.         int             bsize;      /* Buffer size                */
  104.         unsigned short  istemp;     /* Temporary file indicator   */
  105.         unsigned short  flags;      /* File status flags          */
  106.         wchar_t         hold;       /* Ungetc char if no buffer   */
  107.         char            fd;         /* File descriptor            */
  108.         unsigned char   token;      /* Used for validity checking */
  109. }       FILE;                       /* This is the FILE object    */
  110.  
  111. /* Number of files that can be open simultaneously
  112. */
  113. #if defined(__STDC__)
  114. #define FOPEN_MAX (_NFILE_)
  115. #else
  116. #define FOPEN_MAX (_NFILE_)
  117. #define SYS_OPEN  (_NFILE_)
  118. #endif
  119.  
  120. #define FILENAME_MAX 260
  121.  
  122. #ifdef __cplusplus
  123. extern "C" {
  124. #endif
  125.  
  126. /* Standard I/O predefined streams
  127. */
  128. extern  FILE        _RTLENTRY _EXPDATA _streams[];
  129. extern  unsigned    _RTLENTRY _EXPDATA _nfile;
  130.  
  131. #define stdin   (&_streams[0])
  132. #define stdout  (&_streams[1])
  133. #define stderr  (&_streams[2])
  134.  
  135. /* __getStream() is used internally with CG only, but prototyped here for
  136.   consistancy with the 16-bit version.
  137. */
  138. FILE * _RTLENTRY _EXPFUNC __getStream( int );
  139. #ifdef __cplusplus
  140. }
  141. #endif
  142.  
  143.  
  144. #ifdef __cplusplus
  145. extern "C" {
  146. #endif
  147. void    _RTLENTRY _EXPFUNC clearerr(FILE * __stream);
  148. int     _RTLENTRY _EXPFUNC fclose(FILE * __stream);
  149. int     _RTLENTRY _EXPFUNC fflush(FILE * __stream);
  150. int     _RTLENTRY _EXPFUNC fgetc(FILE * __stream);
  151. _WINT_T  _RTLENTRY _EXPFUNC fgetwc(FILE * __stream);
  152. int     _RTLENTRY _EXPFUNC fgetpos(FILE * __stream, fpos_t*__pos);
  153. char  * _RTLENTRY _EXPFUNC fgets(char * __s, int __n, FILE * __stream);
  154. wchar_t* _RTLENTRY _EXPFUNC fgetws(wchar_t * __s, int __n, FILE * __stream);
  155. FILE  * _RTLENTRY _EXPFUNC fopen(const char * __path, const char * __mode);
  156. FILE  * _RTLENTRY _EXPFUNC _wfopen(const wchar_t * __path, const wchar_t * __mode);
  157. int     _RTLENTRY _EXPFUNC fprintf(FILE * __stream, const char * __format, ...);
  158. int     _RTLENTRY _EXPFUNC fwprintf(FILE * __stream, const wchar_t *__format, ...);
  159. int     _RTLENTRY _EXPFUNC fputc(int __c, FILE * __stream);
  160. _WINT_T  _RTLENTRY _EXPFUNC fputwc(_WINT_T __c, FILE * __stream);
  161. int     _RTLENTRY _EXPFUNC fputs(const char * __s, FILE * __stream);
  162. int     _RTLENTRY _EXPFUNC fputws(const wchar_t * __s, FILE * __stream);
  163. _SIZE_T  _RTLENTRY _EXPFUNC fread(void * __ptr, _SIZE_T __size, _SIZE_T __n,
  164.                                  FILE * __stream);
  165. FILE  * _RTLENTRY _EXPFUNC freopen(const char * __path, const char * __mode,
  166.                                    FILE * __stream);
  167. FILE  * _RTLENTRY _EXPFUNC _wfreopen(const wchar_t * __path, const wchar_t * __mode,
  168.                                    FILE * __stream);
  169. int     _RTLENTRY _EXPFUNC fscanf(FILE * __stream, const char * __format, ...);
  170. int     _RTLENTRY _EXPFUNC fwscanf(FILE *__stream, const wchar_t *__format, ...);
  171. int     _RTLENTRY _EXPFUNC fseek(FILE * __stream, long __offset, int __whence);
  172. int     _RTLENTRY _EXPFUNC fsetpos(FILE * __stream, const fpos_t*__pos);
  173. long    _RTLENTRY _EXPFUNC ftell(FILE * __stream);
  174. _SIZE_T  _RTLENTRY _EXPFUNC fwrite(const void * __ptr, _SIZE_T __size, _SIZE_T __n,
  175.                             FILE * __stream);
  176. char  * _RTLENTRY _EXPFUNC gets(char * __s);
  177. wchar_t* _RTLENTRY _EXPFUNC _getws(wchar_t * __s);
  178.  
  179. int     _RTLENTRY _EXPFUNC _pclose(FILE *__stream);
  180.  
  181. void    _RTLENTRY _EXPFUNC perror(const char * __s);
  182. void    _RTLENTRY _EXPFUNC _wperror(const wchar_t * __s);
  183.  
  184. FILE *  _RTLENTRY _EXPFUNC _popen(const char * __command, const char * __mode);
  185. FILE *  _RTLENTRY _EXPFUNC _wpopen(const wchar_t * __command,
  186.                                    const wchar_t * __mode);
  187.  
  188. int     _RTLENTRY _EXPFUNC printf(const char * __format, ...);
  189. int     _RTLENTRY _EXPFUNC wprintf(const wchar_t * __format, ...);
  190. int     _RTLENTRY _EXPFUNC puts(const char * __s);
  191. int     _RTLENTRY _EXPFUNC _putws(const wchar_t * __s);
  192.  
  193. int     _RTLENTRYF _EXPFUNC remove(const char * __path);
  194. int     _RTLENTRYF _EXPFUNC _wremove(const wchar_t * __path);
  195. int     _RTLENTRYF _EXPFUNC rename(const char * __oldname,const char * __newname);
  196. int     _RTLENTRYF _EXPFUNC _wrename(const wchar_t * __oldname,const wchar_t * __newname);
  197. void    _RTLENTRY  _EXPFUNC rewind(FILE * __stream);
  198. int     _RTLENTRY  _EXPFUNC scanf(const char * __format, ...);
  199. int     _RTLENTRY  _EXPFUNC wscanf(const wchar_t * __format, ...);
  200. void    _RTLENTRY  _EXPFUNC setbuf(FILE * __stream, char * __buf);
  201. int     _RTLENTRY  _EXPFUNC setvbuf(FILE * __stream, char * __buf,
  202.                                     int __type, _SIZE_T __size);
  203. int     _RTLENTRY  _EXPFUNC sprintf(char * __buffer, const char * __format, ...);
  204. int     _RTLENTRY  _EXPFUNC swprintf(wchar_t * __buffer, const wchar_t * __format, ...);
  205.  
  206. int     _RTLENTRY  _EXPFUNC sscanf(const char * __buffer,
  207.                                    const char * __format, ...);
  208. int     _RTLENTRY  _EXPFUNC swscanf(const wchar_t * __buffer,
  209.                                    const wchar_t * __format, ...);
  210. char  * _RTLENTRY _EXPFUNC strerror(int __errnum);
  211. FILE  * _RTLENTRY _EXPFUNC tmpfile(void);
  212. char  * _RTLENTRY _EXPFUNC tmpnam(char * __s);
  213. wchar_t * _RTLENTRY _EXPFUNC _wtmpnam(wchar_t * __s);
  214. int     _RTLENTRY _EXPFUNC ungetc(int __c, FILE * __stream);
  215. _WINT_T  _RTLENTRY _EXPFUNC ungetwc(_WINT_T __c, FILE * __stream);
  216. int     _RTLENTRY _EXPFUNC vfprintf(FILE * __stream, const char * __format,
  217.                             void * __arglist);
  218. int     _RTLENTRY _EXPFUNC vfscanf(FILE * __stream, const char * __format,
  219.                             void * __arglist);
  220. int     _RTLENTRYF _EXPFUNC vprintf(const char * __format, void * __arglist);
  221. int     _RTLENTRY _EXPFUNC vscanf(const char * __format, void * __arglist);
  222. int     _RTLENTRY _EXPFUNC vsprintf(char * __buffer, const char * __format,
  223.                         void * __arglist);
  224. int     _RTLENTRY _EXPFUNC vsscanf(const char * __buffer, const char * __format,
  225.                         void * __arglist);
  226. int     _RTLENTRY _EXPFUNC vfwprintf(FILE * __stream, const wchar_t * __format,
  227.                             void * __arglist);
  228. int     _RTLENTRY _EXPFUNC vfwscanf(FILE * __stream, const wchar_t * __format,
  229.                             void * __arglist);
  230. int     _RTLENTRY _EXPFUNC vwprintf(const wchar_t * __format, void * __arglist);
  231. int     _RTLENTRY _EXPFUNC vwscanf(const wchar_t * __format, void * __arglist);
  232. int     _RTLENTRY _EXPFUNC vswprintf(wchar_t * __buffer, const wchar_t * __format,
  233.                         void * __arglist);
  234. int     _RTLENTRY _EXPFUNC vswscanf(const wchar_t * __buffer, const wchar_t * __format,
  235.                         void * __arglist);
  236. int     _RTLENTRY _EXPFUNC _unlink(const char * __path);
  237. int     _RTLENTRY _EXPFUNC _wunlink(const wchar_t * __path);
  238.  
  239. int     _RTLENTRY _EXPFUNC getc(FILE * __fp);
  240. _WINT_T  _RTLENTRY _EXPFUNC getwc(FILE * __fp);
  241. int     _RTLENTRY _EXPFUNC getchar(void);
  242. _WINT_T  _RTLENTRY _EXPFUNC getwchar(void);
  243. int     _RTLENTRY _EXPFUNC putchar(const int __c);
  244. _WINT_T  _RTLENTRY _EXPFUNC putwchar(const _WINT_T __c);
  245. int     _RTLENTRY _EXPFUNC putc(const int __c, FILE * __fp);
  246. _WINT_T  _RTLENTRY _EXPFUNC putwc(const _WINT_T __c, FILE * __fp);
  247. int     _RTLENTRY _EXPFUNC feof(FILE * __fp);
  248. int     _RTLENTRY _EXPFUNC ferror(FILE * __fp);
  249. int     _RTLENTRY _EXPFUNC _fileno(FILE _FAR *__fp);
  250. int     _RTLENTRY _EXPFUNC _flushall(void);
  251. int     _RTLENTRY _EXPFUNC _fcloseall(void);
  252. FILE  * _RTLENTRY _EXPFUNC _fdopen(int __handle, char * __type);
  253. FILE  * _RTLENTRY _EXPFUNC _wfdopen(int __handle, wchar_t * __type);
  254. int     _RTLENTRY _EXPFUNC _fgetchar(void);
  255. _WINT_T  _RTLENTRY _EXPFUNC _fgetwchar(void);
  256. int     _RTLENTRY _EXPFUNC _fputchar(int __c);
  257. _WINT_T  _RTLENTRY _EXPFUNC _fputwchar(_WINT_T __c);
  258. FILE  * _RTLENTRY _EXPFUNC _fsopen (const char * __path, const char * __mode, int __shflag);
  259. FILE  * _RTLENTRY _EXPFUNC _wfsopen (const wchar_t * __path,
  260.                               const wchar_t * __mode, int __shflag);
  261. #ifdef __IN_SOPEN
  262. int  _RTLENTRY  _EXPFUNC _sopen ();
  263. #else
  264. int  _RTLENTRY  _EXPFUNC _sopen (const char *__path, int __access, int __shflag,
  265.                       ... /* unsigned mode */);
  266. #endif
  267. int  _RTLENTRY  _EXPFUNC32 _wsopen (const wchar_t *__path, int __access, int __shflag,
  268.                       ... /* unsigned mode */);
  269. int     _RTLENTRY _EXPFUNC _getw(FILE * __stream);
  270. int     _RTLENTRY _EXPFUNC _putw(int __w, FILE * __stream);
  271. int     _RTLENTRY _EXPFUNC _rmtmp(void);
  272. char  * _RTLENTRY _EXPFUNC _strerror(const char * __s);
  273. char  * _RTLENTRY _EXPFUNC _tempnam(char * __dir, char * __pfx);
  274. wchar_t * _RTLENTRY _EXPFUNC _wtempnam(wchar_t * __dir, wchar_t * __pfx);
  275.  
  276. int      _RTLENTRY _EXPFUNC _fgetc(FILE * __stream);           /* used by getc() macro */
  277. _WINT_T   _RTLENTRY _EXPFUNC _fgetwc(FILE * __stream);
  278. int      _RTLENTRY _EXPFUNC _fputc(char __c, FILE * __stream); /* used by putc() macro */
  279. _WINT_T   _RTLENTRY _EXPFUNC _fputwc(wchar_t __c, FILE * __stream);
  280.  
  281. #if !defined(__STDC__)
  282. int     _RTLENTRY _EXPFUNC flushall(void);
  283. FILE  * _RTLENTRY _EXPFUNC fdopen(int __handle, char * __type);
  284. int     _RTLENTRY _EXPFUNC fputchar(int __c);
  285. int     _RTLENTRY _EXPFUNC fgetchar(void);
  286. int     _RTLENTRY _EXPFUNC fileno(FILE * __fp);
  287. int     _RTLENTRY _EXPFUNC fcloseall(void);
  288. char  * _RTLENTRY _EXPFUNC tempnam(char * __dir, char * __pfx);
  289. int     _RTLENTRY _EXPFUNC rmtmp(void);
  290. int     _RTLENTRY _EXPFUNC unlink(const char * __path);
  291. int     _RTLENTRY _EXPFUNC getw(FILE * __stream);
  292. int     _RTLENTRY _EXPFUNC putw(int __w, FILE * __stream);
  293. int     _RTLENTRY _EXPFUNC sopen (const char *__path, int __access, int __shflag,
  294.                       ... /* unsigned mode */);
  295. #endif
  296.  
  297. #ifdef  __cplusplus
  298. }
  299. #endif
  300.  
  301. /*  The following macros provide for common functions */
  302.  
  303. #if !defined(__CODEGUARD__)
  304.  
  305. #define ferror(f)   ((f)->flags & _F_ERR)
  306. #define feof(f)     ((f)->flags & _F_EOF)
  307. #define fileno(f)   ((f)->fd)
  308. #define _fileno(f)   ((f)->fd)
  309.  
  310. #define getc(f) \
  311.   ((--((f)->level) >= 0) ? (unsigned char)(*(f)->curp++) : \
  312.     _fgetc (f))
  313.  
  314. #define putc(c,f) \
  315.   ((++((f)->level) < 0) ? (unsigned char)(*(f)->curp++=((unsigned char)c)) : \
  316.     _fputc (((unsigned char)c),f))
  317.  
  318. #define getchar()   getc(stdin)
  319. #define getwchar()  getwc(stdin)
  320. #define putchar(c)  putc((c), stdout)
  321. #define putwchar(c) putwc((c), stdout)
  322.  
  323. #endif
  324.  
  325. #define ungetc(c,f) ungetc((c),f)   /* traditionally a macro */
  326.  
  327. #if !defined(RC_INVOKED)
  328.  
  329. /* restore default packing */
  330. #pragma pack(pop)
  331.  
  332. #if defined(__STDC__)
  333. #pragma warn .nak
  334. #endif
  335.  
  336. #endif  /* !RC_INVOKED */
  337.  
  338. #ifdef __cplusplus
  339. } // std
  340. #endif /* __cplusplus */
  341.  
  342. #endif  /* __STDIO_H */
  343.  
  344. #if defined(__cplusplus) && !defined(__USING_CNAME__) && !defined(__STDIO_H_USING_LIST)
  345. #define __STDIO_H_USING_LIST
  346.      using std::FILE;
  347.      using std::__getStream;
  348.      using std::_fcloseall;
  349.      using std::_fdopen;
  350.      using std::_fgetc;
  351.      using std::_fgetchar;
  352.      using std::_fgetwc;
  353.      using std::_fgetwchar;
  354.      using std::_fileno;
  355.      using std::_floatconvert;
  356.      using std::_flushall;
  357.      using std::_fputc;
  358.      using std::_fputchar;
  359.      using std::_fputwc;
  360.      using std::_fputwchar;
  361.      using std::_fsopen;
  362.      using std::_getw;
  363.      using std::_getws;
  364.      using std::_pclose;
  365.      using std::_popen;
  366.      using std::_putw;
  367.      using std::_putws;
  368.      using std::_rmtmp;
  369.      using std::_sopen;
  370.      using std::_streams;
  371.      using std::_strerror;
  372.      using std::_tempnam;
  373.      using std::_unlink;
  374.      using std::_wfdopen;
  375.      using std::_wfopen;
  376.      using std::_wfreopen;
  377.      using std::_wfsopen;
  378.      using std::_wperror;
  379.      using std::_wpopen;
  380.      using std::_wremove;
  381.      using std::_wrename;
  382.      using std::_wsopen;
  383.      using std::_wtempnam;
  384.      using std::_wtmpnam;
  385.      using std::_wunlink;
  386.      using std::clearerr;
  387.      using std::fclose;
  388.      using std::feof;
  389.      using std::ferror;
  390.      using std::fflush;
  391.      using std::fgetc;
  392.      using std::fgetpos;
  393.      using std::fgets;
  394.      using std::fgetwc;
  395.      using std::fgetws;
  396.      using std::fopen;
  397.      using std::fpos_t;
  398.      using std::fprintf;
  399.      using std::fputc;
  400.      using std::fputs;
  401.      using std::fputwc;
  402.      using std::fputws;
  403.      using std::fread;
  404.      using std::freopen;
  405.      using std::fscanf;
  406.      using std::fseek;
  407.      using std::fsetpos;
  408.      using std::ftell;
  409.      using std::fwprintf;
  410.      using std::fwrite;
  411.      using std::fwscanf;
  412.      using std::getc;
  413.      using std::getchar;
  414.      using std::gets;
  415.      using std::getwc;
  416.      using std::getwchar;
  417.      using std::perror;
  418.      using std::printf;
  419.      using std::putc;
  420.      using std::putchar;
  421.      using std::puts;
  422.      using std::putwc;
  423.      using std::putwchar;
  424.      using std::remove;
  425.      using std::rename;
  426.      using std::rewind;
  427.      using std::scanf;
  428.      using std::setbuf;
  429.      using std::setvbuf;
  430.      using std::sprintf;
  431.      using std::sscanf;
  432.      using std::strerror;
  433.      using std::swprintf;
  434.      using std::swscanf;
  435.      using std::tmpfile;
  436.      using std::tmpnam;
  437.      using std::ungetc;
  438.      using std::ungetwc;
  439.      using std::vfprintf;
  440.      using std::vfscanf;
  441.      using std::vfwprintf;
  442.      using std::vfwscanf;
  443.      using std::vprintf;
  444.      using std::vscanf;
  445.      using std::vsprintf;
  446.      using std::vsscanf;
  447.      using std::vswprintf;
  448.      using std::vswscanf;
  449.      using std::vwprintf;
  450.      using std::vwscanf;
  451.      using std::wprintf;
  452.      using std::wscanf;
  453.  
  454. #if !defined(__STDC__)
  455.      using std::flushall;
  456.      using std::fdopen;
  457.      using std::fputchar;
  458.      using std::fgetchar;
  459.      using std::fileno;
  460.      using std::fcloseall;
  461.      using std::tempnam;
  462.      using std::rmtmp;
  463.      using std::unlink;
  464.      using std::getw;
  465.      using std::putw;
  466.      using std::sopen;
  467. #endif // !__STDC__
  468.  
  469. #endif /* __USING_CNAME__ */
  470.